const { contextBridge, ipcRenderer } = require("electron");

///HID接口
contextBridge.exposeInMainWorld('HIDAPI', {
  HIDList: () => ipcRenderer.invoke('get-hid-list'),
  openHID: (vendorId, productId) => ipcRenderer.send('open-hid', vendorId, productId),
  sendData: (message) => ipcRenderer.send('send-data', message),
  onHIDStatus: (callback) => ipcRenderer.on('hid-status', callback),
});

///读写接口
contextBridge.exposeInMainWorld('FileAPI', {
  saveFile: (options) => ipcRenderer.invoke('save-file', options),
  openFile: () => ipcRenderer.invoke('open-file')
});

///读/写 数据
contextBridge.exposeInMainWorld('saveAPI', {
  setItem: (key, value) => ipcRenderer.invoke('set-key-value', key, value),
  getItem: (key) => ipcRenderer.invoke('get-key-value', key)
});